var layer = layui.layer,
	form = layui.form,
	laytpl = layui.laytpl,
	laydate = layui.laydate,
	table = layui.table,
	element = layui.element,
	laypage = layui.laypage,
	$ = layui.jquery;

function formSubmit(url, submit, dataType, func){
	form.on(submit, function(data){
		ajax(url, data.field, dataType, func)
	})
}

function ajax(url, field, dataType, func){
	$.ajax({
		url: base.app + url,
		type: "post",
		data: field,
		dataType: dataType,
		success: func
	})
}

function getlaytpl(sel, data){
	return laytpl($(sel).html()).render(data);
}

function openLayer(url, end){
	 layer.open({
		 type: 2,
		 area:['750px','500px'],
		 fixed: false,
		 maxmin:true,
		 content:base.app+url,
		 end: end
	 })
}

function closeThis(){
	var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
	parent.layer.close(index); //再执行关闭
}

function openConfirm(func, title){
	 layer.confirm(title ? title:"确认进行该操作？", {icon:3,title:"提示"},func)
}

function setPageInfo(elem, count, curr, limit, jump){
	laypage.render({
		 elem: elem,
		 count: count,
		 curr: curr,
		 limit: limit,
		 limits : [ 10, 20, 30, 50 ],
	     layout:['count','prev', 'page','next','limit','refresh','skip'],
	     jump: jump
	 })
	 // 当分页被切换时触发jump方法，该方法有两个参数(obj,first)
	 // obj=当前分页所有选项值，limit，curr什么的
	 // first=是否是首次，一般用于初始化加载时候的判断
}

function renderUpload(id,url,data,done){
	upload.render({
		elem: "#" + id,
		url: base.app + url,
		data:data,
		done: done
	})
}





